package com.zhc.dejingapi.controller;

import com.zhc.dejingapi.pojo.param.QingCommonBackResult;
import com.zhc.dejingapi.pojo.param.QingFcmoroutingMainParam;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 获取清晰报表数据
 * </p>
 *
 * @author zhc
 * @since 2024-08-10
 */
@RestController
@RequestMapping("/qingxiReport")
@CrossOrigin
public class QingXiReportDataFetchController {
    private final JdbcTemplate mysqlJdbcTemplate;

    public QingXiReportDataFetchController(@Qualifier("mySqlJdbcTemplate")JdbcTemplate mysqlJdbcTemplate) {
        this.mysqlJdbcTemplate = mysqlJdbcTemplate;
    }
    @PostMapping("/TableReport")
    public QingCommonBackResult GetTableReportData(@RequestHeader(name = "apiKey") String apiKey,
                                          @RequestBody QingFcmoroutingMainParam param){
        QingCommonBackResult commonBackResult=new QingCommonBackResult();
        try{

            if(param==null){
                throw new Exception("出错：参数不能为空！");
            }
            if(apiKey==null||apiKey.isEmpty()){
                throw new Exception("出错：apiKey不能为空！");
            }


            String strApiKey="B82ADA3F119D42A0B3AC237FDD6C40960A9065EB402A4D73B4D227AF15EF6D88";
            if(!apiKey.equals(strApiKey)){
                throw new Exception("出错：apiKey不正确！");
            }


        }
        catch (Exception e){

            e.printStackTrace();
            commonBackResult.setErrCode(-10012);
            commonBackResult.setErrMsg("出错："+e.getMessage()+"\n"+e.getStackTrace());

        }

        return commonBackResult;
    }



}
